﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Cronus.ViewModel;
using Cronus.ViewModel.Data;

namespace Cronus.View.Totals
{
    public class TaskTotalsControlBase : CronusViewBase<TaskTotalsPresentation>
    { }

    /// <summary>
    /// Interaction logic for TaskTotalsControl.xaml
    /// </summary>
    public partial class TaskTotalsControl : TaskTotalsControlBase
    {
        public TaskTotalsControl() : this(null)
        { }

        public TaskTotalsControl(DataModel dataModel)
        {
            if (null != dataModel)
                Presentation = new TaskTotalsPresentation(dataModel);
            InitializeComponent();
        }
    }

    public class TaskTotalsPresentation : PresentationBase
    {
        public ObservableCollection<TaskSummary> TaskSummaries { get; set; }
        public TaskTotalsPresentation(DataModel data)
            : base(data)
        {
            TaskSummaries = new ObservableCollection<TaskSummary>();
            foreach (var task in data.Tasks)
            {
                // Default settings in SummaryBase are to report using StartOfWeek=DayOfWeek.Monday
                // and StartDate=DateTime.Today.
                TaskSummaries.Add(new TaskSummary(data, task));
            }
            TaskSummaries.Add(new TaskSummary(data)); // Add the summary row
        }
    }
}
